package com.blb.marrysystem.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blb.marrysystem.dao.TbRoomDao;
import com.blb.marrysystem.entity.TbRoom;
import com.blb.marrysystem.service.TbRoomService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (TbRoom)表服务实现类
 *
 * @author makejava
 * @since 2023-01-11 09:22:32
 */
@Service
public class TbRoomServiceImpl implements TbRoomService {
    @Resource
    private TbRoomDao tbRoomDao;

    /**
     * 通过ID查询单条数据
     *
     * @param roomId 主键
     * @return 实例对象
     */
    @Override
    public TbRoom queryById(Integer roomId) {
        return this.tbRoomDao.queryById(roomId);
    }

    /**
     * 分页查询
     *

     * @return 查询结果
     */
    @Override
    public Page<TbRoom> queryByPage() {
        return null;
    }

    /**
     * 新增数据
     *
     * @param tbRoom 实例对象
     * @return 实例对象
     */
    @Override
    public TbRoom insert(TbRoom tbRoom) {
        this.tbRoomDao.insert(tbRoom);
        return tbRoom;
    }

    /**
     * 修改数据
     *
     * @param tbRoom 实例对象
     * @return 实例对象
     */
    @Override
    public TbRoom update(TbRoom tbRoom) {
        this.tbRoomDao.update(tbRoom);
        return this.queryById(tbRoom.getRoomId());
    }

    /**
     * 通过主键删除数据
     *
     * @param roomId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer roomId) {
        return this.tbRoomDao.deleteById(roomId) > 0;
    }
}
